<?php
header("Content-Type: text/html; charset=UTF-8");

$isRequest = $_REQUEST["serviceId"] != NULL;
?>
<!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Service Test</title>
</head>
<body>
<form method="post" action="serviceTest.php">
<table>
	<tr>
		<td width="100">Service Id</td>
		<td><input name="serviceId" type="text" value="<?=$_REQUEST["serviceId"]?>"/></td>
	</tr>
		<tr>
		<td width="100">Client Id</td>
		<td><input name="clientId" type="text" value="<?=$_REQUEST["clientId"]?>"/></td>
	</tr>
	<tr>
		<td width="100">Request Id</td>
		<td><input name="requestId" type="text" value="<?=$_REQUEST["requestId"]?>"/></td>
	</tr>
	<tr>
		<td width="100">params</td>
		<td><textarea name="params" cols="80" rows="15"><?=$_REQUEST["params"]?></textarea></td>
	</tr>
	<tr>
		<td colSpan="2" align="center"><input type="submit" value="테스트" /></td>
	</tr>
</table>
</form>
<?
if ($isRequest){
	require_once "./classes/Logger.php";
	require_once "./classes/ServiceDispatcher.php";
	
	$params = json_decode($_REQUEST["params"], true);
	$result = ServiceDispathcer::doService($_REQUEST["serviceId"], $_REQUEST["requestId"], $_REQUEST["clientId"], $params); 
?>
<pre>
<?
	print_r($params);
?>
</pre>
<table>
	<tr>
		<td width="100">php object</td>
		<td><textarea rows="15" cols="80"><? print_r($result)?></textarea></td>
	</tr>
	<tr>
		<td width="100">json</td>
		<td><textarea rows="15" cols="80"><?=json_encode($result)?></textarea></td>
	</tr>
</table>
<?
}
?>
</body>
</html>